function ActiveMenu(obj){
    $(obj).parents('li').addClass("active");
    $(obj).addClass("active");
}
function ActiveElement(obj){
    $(obj).addClass("active");
}
function DeleteItem(obj, remove){
    if(confirm("Do you really want delete?")){
        $.ajax({
            url: $(obj).attr("href"),
            success: function(data) {
                $(obj).parents(remove+ ':eq(0)').fadeOut('slow', function() {
                    $(obj).parents(remove+ ':eq(0)').remove();
                    ShowMsgbox(data);
                });
            }
        });
    }
}
function CallAjax(obj){
    ShowLoadbox(obj);
    $.ajax({
        url: $(obj).attr("href"),
        success: function(data) {
            ShowMsgbox(data);
            $('.loadbox', obj).remove();
        }
    });
}
function ShowLoadbox(obj){
    $(obj).addClass('relative');
    $(obj).append('<div class="loadbox"><img src="/assets/images/spacer.gif" alt="loading" class="ico iloadbox"/></div>');
}
function ShowMsgbox(html){
    $('body').append('<div class="msgbox">' + html + '</div>')
    $('.msgbox').slideDown().delay(1500).slideUp();
}
function MakeYoutubeURL(obj){
    var url = $(obj).val();
    if(url.indexOf("youtube") != -1){
        $(obj).val(GetUrlVars(url)["v"]);
    }
}
function ViToEn(str) {
    str = str.toLowerCase();
    str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
    str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
    str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
    str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
    str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
    str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
    str = str.replace(/đ/g, "d");
    str = str.replace(/!|@|\$|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\'| |\"|\&|\#|\[|\]|~/g, "-");
    str = str.replace(/-+-/g, "-");
    str = str.replace(/^\-+|\-+$/g, "");
    return str;
}
function GetUrlVars(url)
{
    var vars = [], hash;
    var hashes = url.slice(url.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}